package com.util;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.io.Reader;

/**
 * 工具类
 */
public class MybatisUtils {
    private static SqlSessionFactory sqlSessionFactory = null;
    static {
        try{
            Reader reader =
                    Reasources.getResourceAeader("mybatis-config.xml");
            sqlSessionFactory=
                    new sqlSessionFactoryBuilder().build(reader);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static SqlSession getSession() {
        return sqlSessionFactory.openSession();
    }

    private static class Reasources {
    }
}
